package com.angel.core.util;

import java.util.ArrayList;
import java.util.List;
import java.util.regex.Pattern;

/**
 * @author cheng sir
 * 2016年9月10日上午10:58:01
 */
public class MatcherUtil {

	public static final String PAGE = "^.*第.*[0-9].*页.*$";//验证是否页数
	
	public static final String EMAIL = "^([a-z0-9A-Z]+[-|\\.]?)+[a-z0-9A-Z]@([a-z0-9A-Z]+(-[a-z0-9A-Z]+)?\\.)+[a-zA-Z]{2,}$";//验证邮箱
	
	public static final String IP_ADDR = "(25[0-5]|2[0-4]\\d|[0-1]\\d{2}|[1-9]?\\d)";//验证ip
	
	public static final String ID_CARD = "(^\\d{18}$)|(^\\d{15}$)";//验证身份证
	
	public static final String REGEX_CHINESE = "^[\u4e00-\u9fa5],{0,}$";//验证是否汉字
	
	public static final String SHU_ZI = "^\\d+$";//验证数字
	
	public static final String PDF_MEDICAL = "^.*感谢您来.*体检机构体检.*$";//解析体检库
	
	public static final String AGE_BIRTH_SEX_NAME = "[0-9]{0,3}年龄.*出生年月.*性别.*姓名";//年龄出生年月性别姓名
	
	public static final String HUN_ZJ_MZ_GJ = ".*婚否.*证件号.*民族.*国籍";
	
	public static final String ZD_EMAIL = ".*宅电.*电子邮件";
	
	public static final String BGDH_TXDZ = ".*办公电话.*通讯地址";
	
	public static final String PHONE_GZDW = ".*手机.*工作单位";
	
	public static final String MEDICAL_TIME = ".*年.*月.*日.*星期.*";
	
	public static final String TITLE = "^项目.*结果.*";
	
	public static final String DOCTOR = "(检查医师|检查护士|检验|汇总医生|主检医师|报告医师).*";//检查医师
	/**
	 * 验证是不是显示页面那行
	 * @param page
	 * @return
	 */
	public static boolean isPage(String page){
		return Pattern.compile(PAGE).matcher(page).matches();
	}
	
	/**
	 * 验证是不是汉字
	 * @param page
	 * @return
	 */
	public static boolean isChinese(String chinese){
		return Pattern.compile(REGEX_CHINESE).matcher(chinese).matches();
	}
	
	/**
	 * 验证是不是数字
	 * @param page
	 * @return
	 */
	public static boolean isShu(String shu){
		return Pattern.compile(SHU_ZI).matcher(shu).matches();
	}
	
	/**
	 * 验证邮箱
	 * @return
	 */
	public static boolean isEmail(String email){
		return Pattern.compile(EMAIL).matcher(email).matches();
	}
	
	/**
	 * 验证体检机构
	 * @param args
	 */
	public static boolean isMedical(String medical){
		return Pattern.compile(PDF_MEDICAL).matcher(medical).matches();
	}
	/**
	 * 验证年龄出生年月性别姓名
	 * @return
	 */
	public static boolean isAgeBirthSexNname(String ageBirthSexNname){
		return Pattern.compile(AGE_BIRTH_SEX_NAME).matcher(ageBirthSexNname).matches();
	}
	/**
	 * *婚否.*证件号.*民族.*国籍
	 * @param args
	 */
	public static boolean isHunZjMzGj(String hunZjMzGj){
		return Pattern.compile(HUN_ZJ_MZ_GJ).matcher(hunZjMzGj).matches();
	}
	/**
	 * 宅电.*电子邮件
	 * @param args
	 */
	public static boolean isZdEmail(String zdEmail){
		return Pattern.compile(ZD_EMAIL).matcher(zdEmail).matches();
	}
	/**
	 * *办公电话.*通讯地址
	 * @param args
	 */
	public static boolean isBgdhTxdz(String bgdhTxdz){
		return Pattern.compile(BGDH_TXDZ).matcher(bgdhTxdz).matches();
	}
	/**
	 * *手机.*工作单位
	 * @param args
	 */
	public static boolean isPhoneGzdw(String phoneGzdw){
		return Pattern.compile(PHONE_GZDW).matcher(phoneGzdw).matches();
	}
	/**
	 * 体检时间
	 * @param args
	 */
	public static boolean isMedicalTime(String medicalTime){
		return Pattern.compile(MEDICAL_TIME).matcher(medicalTime).matches();
	}
	/**
	 * 表格头
	 * @param args
	 */
	public static boolean isTitle(String title){
		return Pattern.compile(TITLE).matcher(title).matches();
	}
	/**
	 * 医生
	 * @param args
	 */
	public static boolean isDoctor(String doctor){
		return Pattern.compile(DOCTOR).matcher(doctor).matches();
	}
	
	public static void main(String[] args) {
		boolean matches =isDoctor("检查护士  易云 ");
		System.err.println(matches);
		System.out.println("办公电话".substring(0,"办公电话".indexOf("办公电话")));
		
	}
}
